<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <table>
        <tr>
            <th>
                <input id="check-all" type="checkbox" name="" id="">
            </th>
            <th>表头第2列</th>
            <th>表头第3列</th>
        </tr>
        <tr>
            <td>
                <input class="check-one" type="checkbox" name="" id="">
            </td>
            <td>内容</td>
            <td>内容</td>
        </tr>
        <tr>
            <td>
                <input class="check-one" type="checkbox" name="" id="">
            </td>
            <td>内容</td>
            <td>内容</td>
        </tr>
        <tr>
            <td>
                <input class="check-one" type="checkbox" name="" id="">
            </td>
            <td>内容</td>
            <td>内容</td>
        </tr>
        <tr>
            <td>
                <input class="check-one" type="checkbox" name="" id="">
            </td>
            <td>内容</td>
            <td>内容</td>
        </tr>
    </table>

    <script>

        // 全选按钮
        const checkAll = document.querySelector('#check-all');
        // 下面的所有复选框
        const checkboxes = document.querySelectorAll('.check-one');

        checkAll.addEventListener('click', function () {
            for (const checkbox of checkboxes) {
                checkbox.checked = checkAll.checked;
            }
        });

    </script>
</body>
</html>